@{
	IList<IGrouping<string, IDocument>> categoryGroups = 
		Documents.FromPipeline("Modules")
			.GroupBy(x => {
				IReadOnlyList<OtherComment> categoryComments = x.List<OtherComment>("CategoryComments");
				return categoryComments == null ? string.Empty : categoryComments[0].Html;
			})
			.OrderBy(x => x.Key)
			.ToList();
	foreach(IGrouping<string, IDocument> categoryGroup in categoryGroups)
	{
		if(!string.IsNullOrWhiteSpace(categoryGroup.Key))
		{
			<li class="header">@categoryGroup.Key</li>
		}
					
		foreach(IDocument childDoc in categoryGroup
			.OrderBy(x => x.String("DisplayName")))
		{
			string selectedClass = Model.String("RelativeFilePath") == childDoc.String("RelativeFilePath") ? "selected" : null;
			<li class="@selectedClass">
				<a href="@Context.GetLink(childDoc)">
					@(childDoc.String("DisplayName"))
				</a>
			</li>
		} 
	}	
}